package com.jkl.queryserver.Provider;

import com.jkl.Interface.QueryServer;
import com.jkl.pojo.*;
import com.jkl.queryserver.Provider.DAO.mapper.AccountMapper;
import com.jkl.queryserver.Provider.DAO.mapper.AcctFriendMapper;
import com.jkl.queryserver.Provider.DAO.mapper.MessageMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@DubboService(interfaceClass = QueryServer.class)
public class MySQLQueryServerProvider implements QueryServer {
    private final AccountMapper accountMapper;
    private final AcctFriendMapper acctFriendMapper;
    private final MessageMapper messageMapper;
    @Autowired
    public MySQLQueryServerProvider(AccountMapper accountMapper, AcctFriendMapper acctFriendMapper, MessageMapper messageMapper) {
        this.accountMapper = accountMapper;
        this.acctFriendMapper = acctFriendMapper;
        this.messageMapper = messageMapper;
    }

    @Override
    public Account selectPUSA(String email) {
        return accountMapper.selectPUSA(email);
    }
    @Override
    public Account selectUSA(String email) {
        return accountMapper.selectUSA(email);
    }
    @Override
    public Account selectU(String email){return accountMapper.selectU(email);}
    @Override
    public List<Account> selectLike(String email, String text) {
        return accountMapper.selectLike(email,text);
    }
    @Override
    public List<AppFriend> selectAllFriend(String email) {
        return acctFriendMapper.selectAllFriend(email);
    }
    @Override
    public List<SCApplication> selectApplicationInfo(String email) {
        return acctFriendMapper.selectApplicationInfo(email);
    }
    @Override
    public List<Message> selectUnreceivedMessages(String email, Long lastTime) {
        return messageMapper.selectUnreceivedMessages(email,lastTime);
    }
    @Override
    public List<Message> selectMessages(String email) {
        return messageMapper.selectMessages(email);
    }
}
